package com.crop.back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.crop.back.common.enums.Deleted;
import com.crop.back.common.utils.UserHolder;
import com.crop.back.entity.ProcessingBatch;
import com.crop.back.mapper.ProcessingBatchMapper;
import com.crop.back.service.ProcessingBatchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 加工批次表 服务实现类
 * </p>
 *
 * @author 作者
 * @since 2025-01-20
 */
@Service
public class ProcessingBatchServiceImpl extends ServiceImpl<ProcessingBatchMapper, ProcessingBatch> implements ProcessingBatchService {

    @Override
    public List<Long> getBatchNo() {
        LambdaQueryWrapper<ProcessingBatch> wrapper = new LambdaQueryWrapper<>();
        Long referenceId = UserHolder.getUser().getReferenceId();
        wrapper.eq(ProcessingBatch::getDeleted, Deleted.NOT_DELETED.getCode());
        wrapper.eq(ProcessingBatch::getProcessorId, referenceId);
        List<Long> list = this.list(wrapper).stream().map(ProcessingBatch::getId).toList();
        return list;
    }
}
